﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Thesis_v01
{
   public class AnalyseResponses
   {
      public AnalyseResponses()
      {

      }

      public ArrayList TallyResponses (ArrayList possibleAnswers, ArrayList responses)
      {
         ArrayList tallies = new ArrayList();
         foreach (string answer in possibleAnswers)
         {
            TallyDetail tally = new TallyDetail();
            tally.Answer = answer;
            tally.Tally = FindTotal(answer, responses);

            tallies.Add(tally);
         }

         return tallies;
      }

      private int FindTotal(string comparer, ArrayList set)
      {
         int total = 0;
         foreach (ResponseDetail response in set)
         {
            string responseString = response.Description;
            if (String.Compare(comparer, responseString, true) == 0)
            {
               total++;
            }
         }

         return total;
      }
   }
}
